Ext.override(Ext.grid.feature.Grouping,{
    setGroupHeaderTpl:function(groupIdx,groupData,allGroups,feature){
        var store=feature.view.store,
            defaultHeaderTpl=(new Ext.XTemplate(feature.groupHeaderTpl)).apply(groupData);
        if(feature.showEmptyGroups){
            if(groupData.rows.length==1){
                if(store.getGroups()[groupIdx-1].children[0].get(feature.emptyIndicatorField)==0){return (new Ext.XTemplate(feature.emptyGroupHeaderTpl)).apply(groupData);}
            }
        }
        return defaultHeaderTpl;
    },
    setGroupBodyTpl:function(groupIdx,groupData,allGroups,feature){
        var me=this,store=feature.view.store;
        if(feature.showEmptyGroups){
            if(groupData.rows.length==1){
                if(store.getGroups()[groupIdx-1].children[0].get(feature.emptyIndicatorField)==0){
                    return '<table class="x-grid-table x-grid-table-resizer"><tbody><tr class="x-grid-row"><td class="x-grid-cell x-grid-cell-gridcolumn x-grid-cell-first"></td><div class="x-grid-cell-inner test">'+(new Ext.XTemplate(feature.emptyGroupBodyTpl)).apply(groupData)+'</div></td></tr></tbody></table>';
                }
            }
        }
        return me.recurse(groupData);
    },

    getFeatureTpl:function(values,parent,x,xcount){
        var me=this;
        return[
            '<tpl if="typeof rows !== \'undefined\'">',
            '<tr id="{groupHeaderId}" class="' + Ext.baseCSSPrefix + 'grid-group-hd ' + (me.startCollapsed ? me.hdCollapsedCls : '') + ' {hdCollapsedCls}"><td class="' + Ext.baseCSSPrefix + 'grid-cell" colspan="' + parent.columns.length + '" {[this.indentByDepth(values)]}><div class="' + Ext.baseCSSPrefix + 'grid-cell-inner"><div class="' + Ext.baseCSSPrefix + 'grid-group-title">{collapsed}{[this.setGroupHeaderTpl(xindex,values,parent.rows,this.feature)]}</div></div></td></tr>',
            '<tr id="{groupBodyId}" class="' + Ext.baseCSSPrefix + 'grid-group-body ' + (me.startCollapsed ? me.collapsedCls : '') + ' {collapsedCls}"><td class="'+Ext.baseCSSPrefix+'grid-cell" colspan="' + parent.columns.length + '">{[this.setGroupBodyTpl(xindex,values,parent.rows,this.feature)]}</td></tr>',
            '</tpl>'
        ].join('');
    },

    getFragmentTpl:function(){

        return{
            feature:this,
            setGroupBodyTpl:this.setGroupBodyTpl,
            setGroupHeaderTpl:this.setGroupHeaderTpl,
            indentByDepth:this.indentByDepth,
            depthToIndent:this.depthToIndent

        };
    }
});